package com.ybxx.system.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

import com.ybxx.core.command.QueryFilter;
import com.ybxx.core.dao.impl.BaseDaoImpl;
import com.ybxx.core.web.paging.PagingBean;
import com.ybxx.system.dao.DataRightsDao;
import com.ybxx.system.model.DataRights;
import com.ybxx.system.model.DataRightsChecked;

public class DataRightsDaoImpl extends BaseDaoImpl<DataRights> implements
		DataRightsDao {
	private JdbcTemplate jdbcTemplate;
	public DataRightsDaoImpl(){
		super(DataRights.class);
	}
	public List<DataRightsChecked> queryDataRights(String sql){
		return jdbcTemplate.query(sql, new RowMapper<DataRightsChecked>(){

			public DataRightsChecked mapRow(ResultSet rs, int index)
					throws SQLException {
				DataRightsChecked checked=new DataRightsChecked();
				checked.setId(rs.getString("id"));
				checked.setpId(rs.getString("fid"));
				checked.setName(rs.getString("name"));
				checked.setChecked(rs.getBoolean("checked"));
				return checked;
			}});
	}
	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}
}
